package com.company.repository;

import com.company.model.Comment;
import com.company.model.Company;
import java.util.List;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * 评论相关Repository
 * Created by Tu on 2017/1/1.
 */
@Repository
public interface CommentRepository extends CrudRepository<Comment, Long>,
    JpaSpecificationExecutor<Comment> {

  @Query("FROM Comment u WHERE u.targetId = :companyId and u.deleted=0 and u.content = :content and u.createUser = :ip and u.createUser != '127.0.0.1'")
  List<Comment> findComments(@Param("companyId") Long companyId,
      @Param("content") String content, @Param("ip") String ip);
}
